<!DOCTYPE HTML>
<html>
<head>
    <title>商学院分类</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body style="padding: 0;width: 100%;height: 98%">
<div class="mini-splitter" style="width:100%;height:100%;">
    <div size="100" showCollapseButton="true">
        <div class="mini-fit">
            <ul id="tree1" class="mini-tree" url="/getdata/getBusinessCollegeClassify" style="width:100%;"
                showTreeIcon="true" textField="name" idField="objectId" value="0" parentField="pid" resultAsTree="false"
            >
            </ul>
        </div>
    </div>
    <div showCollapseButton="true">
        <div id="outImg">
            <img id="imgId" src="" alt="" onclick="smallImg()">
        </div>

        <div style="width:99%;">
            <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                <table style="width:100%;">
                    <tr>
                        <td style="width:100%;">
                            <a class="mini-button" iconCls="icon-add" onclick="addItem()">增加</a>
                            <a class="mini-button" iconCls="icon-edit" onclick="editItem()">编辑</a>
                            <a class="mini-button" iconCls="icon-remove" onclick="removeItem()">删除</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <div id="datagrid1" class="mini-datagrid" style="width:99%;height: 90%;"
             url="/getData/getBusinessCollegeSubList" idField="objectId" allowResize="true" onselectionchanged="onSelectionChanged"
             sizeList="[20,30,50,100]" pageSize="20"
        >
            <!--allowCellEdit="true" allowCellSelect="true" multiSelect="true"-->
            <div property="columns">
                <div type="checkcolumn" width="20"></div>
                <div field="objectId" width="80" align="center" headerAlign="center">ID</div>
                <div field="title" width="80" align="center" headerAlign="center">标题</div>
                <div field="createdAt" width="40" align="center" headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss">
                    创建日期
                </div>
                <div field="updatedAt" width="40" align="center" headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss">
                    更新日期
                </div>
            </div>
        </div>


    </div>

</div>
</body>
<script type="text/javascript">
    let flag = 1;
    let classifyOId="5b7ccd42808ca4006415afd4";
    let tribeOId;
    let tribeName;

    mini.parse();
    let tree = mini.get("tree1");
    let grid = mini.get("datagrid1");
    tree.on("nodeselect", function (e) {
        if (e.isLeaf) {
            classifyOId=e.node.objectId
            grid.load({objectId: e.node.objectId});
        } else {
            grid.setData([]);
            grid.setTotalCount(0);
        }
    });
    grid.load({objectId: '5b7ccd42808ca4006415afd4'});
    grid.on("drawcell", function (e) {
        let value = e.value;
        let column = e.column;
        if (column.field == "tribeAvator") {
            if (value) {
                e.cellHtml = '<img class="bigImg" onclick="bigImg()" src="' + value + '?imageMogr2/thumbnail/640x/format/jpg/interlace/1/auto-orient" width="30" height="30" alt="图片">';
            } else {
                e.cellHtml = '<img class="bigImg" onclick="bigImg()"  src="http://7xiuo5.com1.z0.glb.clouddn.com/fgImage.png?imageMogr2/auto-orient/thumbnail/!100x100r/gravity/Center/crop/100x100/quality/80/auto-orient" width="30" height="30" alt="图片">';
            }
        }

        if (column.field == "qrCode") {
            if (value) {
                e.cellHtml = '<img class="bigImg" onclick="bigImgCode()" src="' + value + '" width="30" height="30" alt="图片">';
            } else {
                e.cellHtml = '<img class="bigImg" onclick="bigImgCode()"  src="http://7xiuo5.com1.z0.glb.clouddn.com/fgImage.png?imageMogr2/auto-orient/thumbnail/!100x100r/gravity/Center/crop/100x100/quality/80/auto-orient" width="30" height="30" alt="图片">';
            }
        }

    });


    $("#name,#objectId,#creater,#nickName，#numNumber").bind("keydown", function (e) {
        if (e.keyCode == 13) {
            search();
        }
    });

    function removeItem() {
        let row = grid.getSelected();
        if (row) {
            let objectId  = row.objectId;
            $.ajax({
                url: "/getdata/deleteBusinessCollegeSubItem",
                type: 'post',
                data: {objectId: objectId},
                cache: false,
                success: function (result) {
//            console.log(result);
                    if (result) {
                        alert('删除成功！');
                    } else {
                        alert('删除失败，请重试！');
                        return;
                    }
                    grid.reload();
                },
                error: function (error) {
                    console.log(error)
                }
            });
        } else {
            alert("请选中一条记录");
        }
    };

    function addItem() {
        mini.open({
            url: "/editor/addClassifySubItem?classifyOId="+classifyOId,
            title: "增加", width: 800, height: 800,
            ondestroy: function (action) {
                grid.reload();
            }
        });
    };

    function editItem() {
        var row = grid.getSelected();
        if (row) {
            let objectId  = row.objectId;
            let title  = row.title;
            let content  = row.content;
            mini.open({
                url: "/editor/editClassifySubItem?objectId="+objectId+"&&title="+title+"&&content="+content,
                title: "编辑", width: 800, height: 800,
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        } else {
            alert("请选中一条记录");
        }
    };




    function bigImg() {
        var row = grid.getSelected();
        if (row) {
            if (flag == 1) {
                var path = row.tribeAvator;
                console.log(path);
                $("#imgId").attr('src', path);
                $("#outImg").css('display', 'block');
            }
        }
    }
    function bigImgCode() {
        var row = grid.getSelected();
        if (row) {
            if (flag == 1) {
                var path = row.qrCode;
                $("#imgId").attr('src', path);
                $("#outImg").css('display', 'block');
            }
        }
    }
    function smallImg() {
        $("#outImg").css('display', 'none');
    }


    function onSelectionChanged(e) {
        var tribeGrid = e.sender;
//    tribeGrid.setStyle('height: 52%;');
//    grid2.setStyle('height: 47%;');
        var record = tribeGrid.getSelected();
        if (record) {
            tribeOId = record.objectId;
            tribeName = record.name;
        }
    }




    $("#tribeId,#memberName,#memberId,#memberType").bind("keydown", function (e) {
        if (e.keyCode == 13) {
            searchMembers();
        }
    });


</script>
</html>
